﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

#if net35

namespace System.Threading.Tasks
{
	public class Task
	{
		Thread t;
		public static Task Run(Action method) {
			var t = new Thread(new ThreadStart(method));
			t.Start();
			return new Task()
			{
				t = t
			};
		}

		public bool Wait() {
			return Wait(int.MaxValue);
		}

		public static bool WaitAll(Task[] t, int p)
		{
			return t.All(task =>
			{
				return task.Wait(p);
			});
		}

		public bool Wait(int p)
		{
			return t.Join(p);
		}

		public static void WaitAll(Task[] tasks)
		{
			WaitAll(tasks, int.MaxValue);
		}
	}
}
#endif